package com.xuxu.blog.controller;

import com.xuxu.common.utils.R;
import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @className: UploadController
 * @author: Maxuxu
 * @date: 2022/10/8 11:20
 * @description: 上传业务控制类
 */
@RestController
@ApiModel(value = "UploadController",description = "上传业务")
@Slf4j
@RequestMapping("/blog/files")
public class UploadController {
    @PostMapping("/upload")
    public R UploadFile(MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();
        file.transferTo(new File("D://test/", originalFilename));
        return R.ok("上传成功");
    }
}
